/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GraphsWindowPackage.DocRecordPackage;
import javafx.scene.Node;
import javafx.scene.control.ScrollView;
import javafx.scene.text.Text;
import javafx.scene.layout.LayoutInfo;
import javafx.scene.input.MouseEvent;
import AlertSystem.Window;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;

/**
 * @author quang
 */

public class DocumentView extends Window {
    public var info: String = "";
    public var time: String ="";
    public var infoWindowWidth: Integer = 450;
    public var infoWindowHeight: Integer = 450;
    public var x: Number;
    public var y: Number;
    public var viewHeight: Number;

    public override function create(): Node {
        return Circle {
            var stage: Stage = null;
            var scaleY = 1.0;
            centerX: x
            centerY: y
            radius: this.circleRadius
            fill: Color.BLACK
            opacity: 0.5
            scaleX: 0.4
            scaleY: bind scaleY
            onMouseClicked: function(e: MouseEvent): Void {
                scaleY = 2.0;
                if (stage == null) {
                    stage = Stage {
                        title: time
                        onClose: function () { scaleY = 1.0; stage = null; }
                        x: e.screenX - infoWindowWidth * 0.5
                        y: e.screenY + 20
                        width: infoWindowWidth
                        height: infoWindowHeight
                        scene: Scene {
                            content: [
                                ScrollView {
                                    layoutInfo: LayoutInfo {
                                        width: bind stage.width - 20
                                        height: bind stage.height - 20
                                    }
                                    node: Text {
                                        wrappingWidth: bind stage.width - 30
                                        content: "\n{info}"
                                    }
                                }
                            ]
                        }
                    }
                }
                else {
                    stage.close();
                }
            }
        };
    }
}


